﻿using FastSocket.SocketBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace SocketTool.Com.Args
{
    public class ConnectionArgs : EventArgs
    {
        // 摘要:
        //     return the connection is active.
        public bool Active { get; private set; }
        //
        // 摘要:
        //     get the connection id.
        public long ConnectionID { get; private set; }
        //
        // 摘要:
        //     get the connection latest active time.
        public DateTime LatestActiveTime { get; private set; }
        //
        // 摘要:
        //     获取本地IP地址
        public IPEndPoint LocalEndPoint { get; private set; }
        //
        // 摘要:
        //     获取远程IP地址
        public IPEndPoint RemoteEndPoint { get; private set; }

        public IConnection Connection { get; private set; }

        public ConnectionArgs(bool active,
                                        long connectionID,
                                        DateTime latestActiveTime,
                                        IPEndPoint localEndPoint,
                                        IPEndPoint remoteEndPoint)
        {
            this.Active = active;
            this.ConnectionID = connectionID;
            this.LatestActiveTime = latestActiveTime;
            LocalEndPoint = localEndPoint;
            RemoteEndPoint = remoteEndPoint;
        }

        public ConnectionArgs(IConnection connection)
        {
            this.Active = connection.Active;
            this.ConnectionID = connection.ConnectionID;
            this.LatestActiveTime = connection.LatestActiveTime;
            LocalEndPoint = connection.LocalEndPoint;
            RemoteEndPoint = connection.RemoteEndPoint;
            this.Connection = connection;
        }
    }
}
